import Vue from 'vue'
import App from './App'
import router from './router'



// 导入element-ui的js库及css
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)

//引用粒子特效插件
import VueParticles from 'vue-particles'  
Vue.use(VueParticles)

//引用echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
//时间格式化
import moment from 'moment'
Vue.prototype.$moment = moment

// 引用axios，并设置基础URL为后端服务api地址
var axios = require('axios')
axios.defaults.baseURL = 'http://localhost:8086' //此处是https协议如果不是改成http
    // 将API方法绑定到全局
Vue.prototype.$axios = axios
axios.defaults.withCredentials = true;// 允许跨域携带cookie
 //给axios添加请i去拦截器
 axios.interceptors.request.use(
    //  function (config) {
   config =>{
    // Do something before request is sent
    if(localStorage.getItem('Authentication')){
      // 如果令牌存在 将令牌添加到请求头部中 key值为Authentication
      config.headers.Authentication = localStorage.getItem('Authentication');
    }
    return config;
  },
  error=> {
    // Do something with request error
    return Promise.reject(error);
  });
new Vue({
    el: '#app',
    router,
    components: { App },

    template: '<App/>'
})